home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
music4c.sit
/
Music4C Folder
/
SFConvert folder
/
progressDialog.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-25
|
2KB
|
91 lines
#include "SFConvert.h"
static int type;
static DialogPtr myDialog;
static int item;
static Handle aHand;
static Rect prgBox;
static double barStep;
static GrafPtr save_port;
static int NumberOfRecordsToWrite;
static int rightPoint;
static char c;
static Rect aRect;
static Rect tRect;
static EventRecord event;
static Point where;
extern long RecLength;
extern long fileSize;
extern int nrec;
void SetProgressDialog()
{
Rect tempRect;
GetPort(&save_port);
myDialog = GetNewDialog(DISPLAY_DIALOG, NIL, (WindowPtr) -1);
tempRect.top = myDialog->portRect.top;
tempRect.left = myDialog->portRect.left;
tempRect.bottom = myDialog->portRect.bottom;
tempRect.right = myDialog->portRect.right;
tempRect.top = ((screenBits.bounds.bottom - screenBits.bounds.top) - (tempRect.bottom - tempRect.top)) / 2;
tempRect.left = ((screenBits.bounds.right - screenBits.bounds.left) - (tempRect.right - tempRect.left)) / 2;
MoveWindow(myDialog, tempRect.left, tempRect.top, TRUE);
ParamText("\p", "\p", "\p", "\p");
ShowWindow(myDialog);
DrawDialog(myDialog);
SelectWindow(myDialog);
SetPort(myDialog);
GetDItem(myDialog, 1, &type, &aHand, &prgBox);
PenSize(3, 3);
InsetRect(&prgBox, -4, -4);
FrameRoundRect(&prgBox, 16, 16);
PenSize(1, 1);
GetDItem(myDialog, 2, &type, &aHand, &prgBox);
NumberOfRecordsToWrite = (int) ((fileSize / RecLength) + 0.5);
barStep = (double)(prgBox.right - prgBox.left ) / (double)NumberOfRecordsToWrite;
FrameRect(&prgBox);
}
Boolean UpdateProgressDialog()
{
rightPoint = prgBox.left + (nrec * barStep);
if ( rightPoint > prgBox.right )
rightPoint = prgBox.right;
if ( nrec == NumberOfRecordsToWrite )
rightPoint = prgBox.right;
SetRect(&aRect, prgBox.left, prgBox.top, rightPoint, prgBox.bottom);
FillRect(&aRect, gray);
if ( GetNextEvent(mDownMask, &event) ) {
where = event.where;
GlobalToLocal(&where);
GetDItem(myDialog, 1, &type, &aHand, &tRect);
if ( PtInRect(where, &tRect)) {
InitCursor();
InvertRect(&tRect);
return(FALSE);
}
}
return(TRUE);
}
void DisposeProgDialog()
{
DisposDialog(myDialog);
}